/*
 * Huawei Software Technologies Co., Ltd. Copyright 1998-2009, All rights reserved.
 * 文件名  :CtmsSoapBindingImpl.java
 * 创建人  :yuebinyao
 * 创建时间:2013-3-18
 */
package com.cimp.service.c2.server;

import java.rmi.RemoteException;

import org.apache.commons.lang3.StringUtils;

import com.cimp.service.c2.UpstreamService;
import com.cimp.util.common.ContextHolder;

public class CtmsSoapBindingImpl implements CSPResponse {
    @Override
    public CSPResult resultNotify(String cspId, String lspId, String correlateID, int cmdResult, String resultFileURL) throws RemoteException {

        CSPResult res = new CSPResult();
        // 判断相关性ID是否为空
        if (StringUtils.isEmpty(correlateID)) {
            res.setResult(Integer.parseInt("-4003"));
            res.setErrorDescription("CorrelateID is null!");

        } else {
            try {
                // 相关性ID(correlateID）为工单ID获取工单信息
                UpstreamService upstreamService = (UpstreamService) ContextHolder.getBean("upstreamService");
                if (cmdResult == 0) {
                    upstreamService.updateDistributeState(correlateID,"处理成功");
                } else {
                    upstreamService.updateDistributeState(correlateID,"处理失败\n"+resultFileURL);
                }
//                notifyFinish(lspId, note, cmdResult, resultFileURL, false);
                res.setResult(Integer.parseInt("0"));
            } catch (Exception e) {
                res.setResult(Integer.parseInt("-3000"));
                res.setErrorDescription(e.getMessage());
            }

        }

        return res;
    }
}
